package com.javaGame.role;

import com.javaGame.util.ImageChange;

import java.awt.*;

/**
 * 花瓣类
 */
public class Flower extends BaseRole{
    /**花瓣图片*/
    public static Image[] flowerImg;
    /**图片切换对象*/
    private ImageChange imageChange = new ImageChange(3);
    /**移动方向*/
    private int direction;
    /**右上常量*/
    public static final int RIGHTUP = 0;
    /**左下常量*/
    public static final int LEFTDOWN = 1;
    /**移动速度*/
    private int speed;

    public Flower(int direction) {
        super((int)(Math.random()*1000), (int)(Math.random()*700), 0, 0);
        this.width = (int)(Math.random()*30 + 10);
        this.height = this.width;
        this.speed = (int)(Math.random()*10 + 4);
        this.direction = direction;
    }

    @Override
    public void move() {
        this.currentImg = imageChange.change(flowerImg);
        if(this.direction == LEFTDOWN){
            this.x -= speed;
            this.y += speed;
        }
        else if(this.direction == RIGHTUP){
            this.x += speed;
            this.y -= speed;
        }
    }
}
